package com.wgj.android.zfp;

import android.util.Log;

import com.google.gson.Gson;
import com.wgj.android.http.weixin.WeiXinCacheUtil;
import com.wgj.android.http.weixin.model.CleanInfo;

import java.util.LinkedList;

/**
 * Created by Administrator on 2017/11/28.
 */

public class CleanFirendsTaskManager {
    private static final String TAG="CleanFirendsTaskManager";

    //修改备注队列
    private LinkedList<ModifyTask> modifyTasks;

    // 检测好友队列
    private LinkedList<CleanFirendsTask> cleanFirendsTasks;
    private static CleanFirendsTaskManager cleanFirendsTaskManager;
    public static synchronized CleanFirendsTaskManager getInstance() {
        if (cleanFirendsTaskManager == null) {
            cleanFirendsTaskManager = new CleanFirendsTaskManager();
        }
        return cleanFirendsTaskManager;
    }
    private CleanFirendsTaskManager() {
         cleanFirendsTasks = new LinkedList<CleanFirendsTask>();
         modifyTasks = new LinkedList<ModifyTask>();
    }

    //添加一个清粉任务
    public void addCleanFiredsTask(CleanFirendsTask cleanFirendsTask) {
        synchronized (cleanFirendsTasks) {
            Log.i(TAG,"add task:"+cleanFirendsTask.getToNickName());
            cleanFirendsTasks.addLast(cleanFirendsTask);

        }
    }

    //添加一个修改备注的任务
    public void addModifyTask(ModifyTask modifyTask){
        synchronized (modifyTasks){
            Log.i(TAG,"add modifyTask:"+modifyTask.getToNickName());
            modifyTasks.addLast(modifyTask);
        }
    }

    //获取一个修改备注的任务
    public ModifyTask getModifyTask(){
        synchronized (modifyTasks){
            if (modifyTasks.size() > 0){
                return modifyTasks.removeFirst();
            }
            return null;
        }
    }

    /**
     * 获取一个清粉任务
     * @return
     */
    public CleanFirendsTask getCleanFirendTask() {
        synchronized (cleanFirendsTasks) {
            if (cleanFirendsTasks.size() > 0) {
                CleanFirendsTask cleanFirendsTask = cleanFirendsTasks.removeFirst();
                return cleanFirendsTask;
            }
        }
        return null;
    }
    public  int getModifyTaskSize(){
        return  modifyTasks.size();
    }
    public  int  getSize(){
        return  cleanFirendsTasks.size();
    }
    public void  clear(){
        synchronized (cleanFirendsTasks) {
            cleanFirendsTasks.clear();
            modifyTasks.clear();
        }
    }
}
